home *** CD-ROM | disk | FTP | other *** search
- {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- (c) TechInsite Pty. Ltd.
- PO Box 429, Abbotsford, Melbourne. 3067 Australia
- Phone: +61 3 9419 6456
- Fax: +61 3 9419 1682
- Web: www.techinsite.com.au
- EMail: peter_hinrichsen@techinsite.com.au
-
- Created: Jan 2000
-
- Notes: Business object model for the Address book demo
-
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
- unit Adrs_BOM;
-
- interface
- uses
- tiPtnVisitor
- ,tiPerObjAbs
- ,Classes
- ;
-
- type
-
- // A list of TPerson objects, with some published properties for display in a
- // TtiTreeView
- //----------------------------------------------------------------------------
- TPersonList = class( TVisList )
- protected
- function GetCaption : string ; override ;
- published
- property Caption ;
- property List ;
- end ;
-
- // A list of TAddress objects
- //----------------------------------------------------------------------------
- TAddressList = class( TVisList )
- protected
- published
- end;
-
- // A list of TEAddress objects
- //----------------------------------------------------------------------------
- TEAddressList = class( TVisList )
- protected
- published
- end;
-
- // The TAdrsBook class. Top of the tree of the Address Book BOM
- //----------------------------------------------------------------------------
- TAdrsBook = class( TPerObjAbs )
- private
- FPersonList : TPersonList ;
- protected
- function GetCaption : string ; override ;
- published
- property People : TPersonList read FPersonList ;
- property Caption ;
- public
- constructor Create ; override ;
- destructor Destroy ; override ;
- end ;
-
-
- // TPerson class. Holds information about a person
- //----------------------------------------------------------------------------
- TPerson = class( TPerObjAbs )
- private
- FAddressList : TAddressList ;
- FEAddressList : TEAddressList ;
- FsFirstname: string;
- FsLastName: string;
- FsInitials : string ;
- FsTitle: string;
- FsNotes: string;
- protected
- function GetCaption : string ; override ;
- published
- property Caption ;
- property EAddressList : TEAddressList read FEAddressList ;
- property AddressList : TAddressList read FAddressList ;
- public
- constructor Create ; override ;
- destructor Destroy ; override ;
- property LastName : string
- read FsLastName
- write FsLastName ;
- property FirstName : string
- read FsFirstname
- write FsFirstName ;
- property Title : string
- read FsTitle
- write FsTitle ;
- property Initials : string
- read FsInitials
- write FsInitials ;
- property Notes : string
- read FsNotes
- write FsNotes ;
- end ;
-
-
- // The TAddress class. Holds conventional ( street & postage ) address info
- //----------------------------------------------------------------------------
- TAddress = class( TPerObjAbs )
- private
- FsLines : string ;
- FsState : string;
- FsCountry: string;
- FsPCode: string;
- FsAdrsType: string;
- function GetText: string;
- protected
- published
- property AdrsType : string
- read FsAdrsType
- write FsAdrsType ;
- property Text : string read GetText ;
- public
- property Country : string
- read FsCountry
- write FsCountry ;
-
- property Lines : string
- read FsLines
- write FsLines ;
- property State : string
- read FsState
- write FsState ;
- property PCode : string
- read FsPCode
- write FsPCode ;
- end ;
-
- // The TEAddress class. Holds info about an EAddress like phone number or EMail
- //----------------------------------------------------------------------------
- TEAddress = class( TPerObjAbs )
- private
- FsText: string;
- FEAdrsType: string;
- protected
- function GetCaption : string ; override;
- published
- property EAdrsType : string
- read FEAdrsType
- write FEAdrsType ;
- property Text : string
- read FsText
- write FsText ;
- public
- property Caption ;
- end ;
-
-
- implementation
- uses
- tiUtils
- ;
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- // *
- // * TAdrsBook
- // *
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- constructor TAdrsBook.Create;
- begin
- inherited;
- FPersonList := TPersonList.Create ;
- end;
-
- //------------------------------------------------------------------------------
- destructor TAdrsBook.Destroy;
- begin
- FPersonList.Free ;
- inherited;
- end;
-
- //------------------------------------------------------------------------------
- function TAdrsBook.GetCaption: string;
- begin
- result := 'Address book' ;
- end;
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- // *
- // * TPerson
- // *
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- constructor TPerson.Create;
- begin
- inherited;
- FAddressList := TAddressList.Create ;
- FEAddressList := TEAddressList.Create ;
- end;
-
- //------------------------------------------------------------------------------
- destructor TPerson.Destroy;
- begin
- FAddressList.Free ;
- FEAddressList.Free ;
- inherited;
- end;
-
- //------------------------------------------------------------------------------
- function TPerson.GetCaption: string;
- begin
- result := LastName + ', ' + FirstName ;
- end;
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- // *
- // * TEAddress
- // *
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- function TEAddress.GetCaption: string;
- begin
- result := EAdrsType + ' ' + Text ;
- end;
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- // *
- // * TPersonList
- // *
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- function TPersonList.GetCaption: string;
- begin
- result := 'People' ;
- end;
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- // *
- // * TAddress
- // *
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- function TAddress.GetText: string;
- begin
- result := tiStrTran( Lines, #13+#10, ', ' ) + ' '
- + State + PCode + Country ;
- end ;
-
- end.
-